﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace HigLabo.Net.Twitter
{
    public partial class TwitterClient
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="placeName"></param>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <returns></returns>
        public Places GetGeoSimilarPlaces(String placeName, Double latitude, Double longitude)
        {
            GetGeoSimilarPlacesCommand command = new GetGeoSimilarPlacesCommand() { Name = placeName, Latitude = latitude, Longitude = longitude };
            return GetGeoSimilarPlaces(command);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public Places GetGeoSimilarPlaces(GetGeoSimilarPlacesCommand command)
        {
            String jsonText = this.GetResultText(TwitterApiUrl.Version1_1.Geo.GetGeoSimilarPlacesUrl, command);
            return new Places(jsonText);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public Places GetGeoSearch(GetGeoSearchCommand command)
        {
            String jsonText = this.GetResultText(TwitterApiUrl.Version1_1.Geo.GetGeoSearchUrl, command);
            return new Places(jsonText);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <returns></returns>
        public Places GetGeoReverseGeoCode(Double latitude, Double longitude)
        {
            GetReverseGeoCodeCommand command = new GetReverseGeoCodeCommand() { Latitude = latitude, Longitude = longitude };
            return GetGeoReverseGeoCode(command);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public Places GetGeoReverseGeoCode(GetReverseGeoCodeCommand command)
        {
            String jsonText = this.GetResultText(TwitterApiUrl.Version1_1.Geo.GetGeoReverseGeoCodeUrl, command);
            return new Places(jsonText);
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="placeID"></param>
        /// <returns></returns>
        public Place GetGeoPlace(String placeID)
        {
            GetGeoPlaceCommand command = new GetGeoPlaceCommand() { PlaceID = placeID };
            return GetGeoPlace(command);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public Place GetGeoPlace(GetGeoPlaceCommand command)
        {
            String url = String.Format(TwitterApiUrl.Version1_1.Geo.GetGeoPlaceByIDUrl, command.PlaceID);
            String jsonText = this.GetResultText(url, command);
            return new Place(jsonText);
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="parentPlaceID"></param>
        /// <param name="token"></param>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <returns></returns>
        public Place CreateGeoPlace(String name, String parentPlaceID, String token, Double latitude, Double longitude)
        {
            PostGeoPlaceCommand command = new PostGeoPlaceCommand()
            {
                Name = name,
                ContainedWithin = parentPlaceID,
                Token = token,
                Latitude = latitude,
                Longitude = longitude
            };
            return CreateGeoPlace(command);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public Place CreateGeoPlace(PostGeoPlaceCommand command)
        {
            String jsonText = this.GetResultText(TwitterApiUrl.Version1_1.Geo.PostGeoPlaceUrl, command);
            return new Place(jsonText);
        }
    }
}
